﻿using System.Runtime.Serialization;
using System.Xml.Linq;
using NCMIS.ObjectModel.MetaData;

namespace NCMIS.ObjectModel
{
    /// <summary>
    /// Represents a property of a CMIS object. A property holds zero or more typed data values. A property may be single-valued or
    /// multi-valued. A single-valued property contains a single data value, whereas a multi-valued property contains an ordered list
    /// of data values of the same type. AKA Attributes (in the spec).
    /// </summary>
    [DataContract(Name = "cmisProperty", Namespace = CmisNs.Cmis)]
    [KnownType(typeof(CmisPropertyBoolean))]
    [KnownType(typeof(CmisPropertyDateTime))]
    [KnownType(typeof(CmisPropertyDecimal))]
    [KnownType(typeof(CmisPropertyHtml))]
    [KnownType(typeof(CmisPropertyId))]
    [KnownType(typeof(CmisPropertyInteger))]
    [KnownType(typeof(CmisPropertyString))]
    public class CmisProperty
    {
        /// <summary>
        /// Unique identifier of a property within an object.
        /// </summary>
        [DataMember(Name = "propertyDefinitionId")]
        public string PropertyDefinitionId
        {
            get;
            set;
        }

        /// <summary>
        /// The underlying repository's name for the property.
        /// </summary>
        [DataMember(Name = "localName", EmitDefaultValue = false)]
        public string LocalName
        {
            get;
            set;
        }

        /// <summary>
        /// A display name for presentation by application.
        /// </summary>
        [DataMember(Name = "displayName")]
        public string DisplayName
        {
            get;
            set;
        }

        /// <summary>
        /// A query name for query operations on properties.
        /// </summary>
        [DataMember(Name = "queryName")]
        public string QueryName
        {
            get;
            set;
        }

        /// <summary>
        /// The value of the property.
        /// </summary>
        [DataMember(Name = "value")]
        public string @Value
        {
            get;
            set;
        }

        /// <summary>
        /// Returns a <see cref="System.Xml.Linq.XElement"/> RestAtom representation of this instance.
        /// </summary>
        /// <returns>A <see cref="System.Xml.Linq.XElement"/> object representation.</returns>
        public virtual XElement ToXElement()
        {
            return null;
        }
    }
}
